package model

//RawMachineStatus 结构体
type Raw_machine_status struct {
	Tid        int
	Machine_ip string
	Raw_data   []byte
	Dtime      string
}

// 解析 Raw_machine_conf 原始数据
func (r *Raw_machine_status) Interpret() *Log_machine_status {

	var machine_statu = Log_machine_status{}

	machine_statu.Status = int(r.Raw_data[1])
	machine_statu.Progress = int(r.Raw_data[3])
	machine_statu.Front_speed = int(uint16(r.Raw_data[4]<<8) + uint16(r.Raw_data[5]))

	machine_statu.Average_speed = int(uint16(r.Raw_data[8]<<8) + uint16(r.Raw_data[9]))
	machine_statu.Spin_length = int(uint16(r.Raw_data[10]<<8) + uint16(r.Raw_data[11]))
	machine_statu.Theory_length = int(uint16(r.Raw_data[14]<<8) + uint16(r.Raw_data[15]))
	machine_statu.Actual_length = int(uint16(r.Raw_data[28]<<8) + uint16(r.Raw_data[29]))
	machine_statu.Temperature = int((r.Raw_data[30] << 8) + r.Raw_data[31])

	machine_statu.Broken_boot = int((r.Raw_data[46] << 8) + r.Raw_data[47])
	machine_statu.Broken_total = int((r.Raw_data[48] << 8) + r.Raw_data[49])

	machine_statu.Max_feed = int((r.Raw_data[54] << 8) + r.Raw_data[55])
	machine_statu.Prestart = int(r.Raw_data[60])
	machine_statu.Start_delay = int(r.Raw_data[61])
	machine_statu.Run_flag = int(r.Raw_data[62])
	machine_statu.Run_state = int(r.Raw_data[63])
	machine_statu.Doff_delay = int(r.Raw_data[64])
	machine_statu.Doff_flag = int(r.Raw_data[65])

	machine_statu.Machine_ip = r.Machine_ip

	return &machine_statu
}
